package com.Day6;

/**
 * Copyright (C), 2018-2021, 若若叶
 * Author: Hx162
 * Date: 2021/7/13 12:27
 * FileName: Array
 * Description: 一维数组、二维数组及遍历
 */
public class Array {

    /**
     * 一维数组
     * @return
     */
    public static int[] arrayYi(){
        //静态初始化
        int[] array1 = {22,33,13,14};

        //动态初始化
        int[] array2 = new int[5];
        //赋值
        array2[0] = 22;  //第1个值
        array2[1] = 33;  //第2个值
        array2[2] = 13;  //第3个值
        array2[3] = 14;  //第4个值
        array2[4] = 520;  //第5个值

        int[] array = new int[10];
        //把array1的值复制到array中
        System.arraycopy(array1,0,array,0,array1.length);
        //把array2的值复制到array中
        System.arraycopy(array2,0,array,array1.length,array2.length);

        return array;
    }

    public static void arrayPrintYi(int[] array){
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }
    public static void arrayPrintEr(int[][] array){
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }



    public static int[][] arrayEr(){
        //静态初始化
        int[][] array = {{1,2,3},{2,3,4},{3,4,5,6}};
        return array;
    }

    public static void main(String[] args) {
//        int[] a = arrayYi();
//        arrayPrintYi(a);
        arrayPrintYi(arrayYi());
        arrayPrintEr(arrayEr());
    }




}
